Skip to content

Set rpath with cmake for CUDA build#2932

Merged
zcbenz merged 1 commit into
mainfrom
cmake-cuda-rpath
Dec 19, 2025
Merged

Set rpath with cmake for CUDA build#2932
zcbenz merged 1 commit into
mainfrom
cmake-cuda-rpath

Conversation

@zcbenz
Copy link
Copy Markdown
Collaborator

@zcbenz zcbenz commented Dec 19, 2025

Set RPATH with cmake directly when building python bindings instead of editing the wheel file with a script.

The RPATH is slightly changed though, before:
$ORIGIN/../../mlx_cuda_13.libs:$ORIGIN/../../nvidia/cublas/lib:$ORIGIN/../../nvidia/cuda_nvrtc/lib:$ORIGIN/../../nvidia/cudnn/lib:$ORIGIN/../../nvidia/nccl/lib

after:
$ORIGIN/../../nvidia/cublas/lib:$ORIGIN/../../nvidia/cuda_nvrtc/lib:$ORIGIN/../../nvidia/cudnn/lib:$ORIGIN/../../nvidia/nccl/lib:$ORIGIN/../../mlx_cuda_13.libs

which I think should be fine.

The repair_linux.sh can also be removed similarly, which I will start another PR.

Comment on lines +159 to +169
if(MLX_BUILD_PYTHON_BINDINGS)
set_property(
TARGET mlx
APPEND
PROPERTY INSTALL_RPATH
# The paths here should match the install_requires in setup.py.
"$ORIGIN/../../nvidia/cublas/lib"
"$ORIGIN/../../nvidia/cuda_nvrtc/lib"
"$ORIGIN/../../nvidia/cudnn/lib"
"$ORIGIN/../../nvidia/nccl/lib")
endif()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm building python locally and using the system installed libraries that will still work right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it still works, setting RPATH does not remove other lib search paths.

Copy link
Copy Markdown
Member

@awni awni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@zcbenz zcbenz merged commit b2e2b19 into main Dec 19, 2025
37 checks passed
@zcbenz zcbenz deleted the cmake-cuda-rpath branch December 19, 2025 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants